package com.springboot.killingsystem.redis;

public abstract class BasePrefix implements KeyPrefix {

    private final int expireSeconds;

    private final String prefix;

    public BasePrefix(String prefix) { // 0代表永不过期
        this(0, prefix);
    }

    public BasePrefix(int expireSeconds, String prefix) {
        this.expireSeconds = expireSeconds;
        this.prefix = prefix;

    }
    /**
     *
     * @return
     *  0 默认代表永不过期
     */
    @Override
    public int expireSecond() {
        return expireSeconds;
    }

    @Override
    public String getPrefix() {
        String className = getClass().getSimpleName();
        return className + ":" + prefix;
    }

}
